package com.wellsantos.dgwt.home.client.view;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.googlecode.dgwt.client.dijit.Dijit;
import com.googlecode.dgwt.client.dijit.HTML;
import com.googlecode.dgwt.client.dijit.form.Button;
import com.googlecode.dgwt.client.dijit.layout.ScrollPanel;
import com.wellsantos.dgwt.client.view.MenuViewBase;
import com.wellsantos.dgwt.home.client.Home;
import com.wellsantos.dgwt.papelaria.client.Papelaria;

public class MenuView extends BaseView implements MenuViewBase {

    /**
     * TODO(wellsantos): renderizar o menu 
     * 		com algum componente como AccordionPanel ou outro 
     */
    
    private ScrollPanel scrollPanel = new ScrollPanel();
    private VerticalPanel mainPanel = new VerticalPanel();
    
    private Button btnHome = new Button(MESSAGE_RESOURCES.menuHome());
    private Button btnLogin = new Button(MESSAGE_RESOURCES.menuLogin());
    private Button btnCreditos = new Button(MESSAGE_RESOURCES.menuCreditos());

    private Button btnPapelaria = new Button(MESSAGE_RESOURCES.menuPapelaria());
    private Button btnFormWidgets = new Button("Form Widgets");

    
    public MenuView() {
        mainPanel.setWidth("100%");
        mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        
        mainPanel.add(btnHome);
        mainPanel.add(btnLogin);
        mainPanel.add(btnCreditos);
        mainPanel.add(new HTML("<hr />ShowCases<hr />"));
        mainPanel.add(btnPapelaria);
        mainPanel.add(btnFormWidgets);
        
        scrollPanel.add(mainPanel);
        btnHome.setStyleProperty("marginTop", "10px");
        
        Dijit.query("sizeableElement", btnHome, btnLogin, btnCreditos).setStyle("width", "100px");
        
        
        btnHome.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Home.getWelcomeView().show();
            }
        });

        btnLogin.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Home.getLoginView().show();
            }
        });

        btnPapelaria.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Papelaria.getMainView().show();
            }
        });
        
        btnFormWidgets.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Home.getFormWidgetsView().show();
            }
        });
    }

    @Override
    public Panel getContainerWidget() {
        return mainPanel;
    }

    @Override
    public Widget getWidget() {
        return scrollPanel;
    }

    @Override
    public String getTitle() {
        return MESSAGE_RESOURCES.labelMenu();
    }

}
